<?php

namespace App\Http\Controllers\Api\V1\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Zhuzhichao\BankCardInfo\BankCard;

class BankCardResource extends JsonResource
{
    public function toArray($request)
    {
    	$data = $this->resource;
        return [
	        'id' => (int)$data->id,
	        'cert_number' => (string)$data->cert_number,
	        'bank_name' => (string)$data->bank_name,
	        'bank_abbr' => (string)$data->bank_abbr,
	        'created_at' => (string)$data->created_at,
	        'icon' => !empty($data->bank_abbr) ? BankCard::getBankImg($data->bank_abbr) : '',
	        'logo' => !empty($data->bank_abbr) ? "https://banklogo.yfb.vercel.app/resource/logo/{$data->bank_abbr}.png" : '',
	        'real_name' => (string)$data->real_name,
	        'method' => $data->method,
	        'alipay_real_name' => $data->alipay_real_name,
	        'alipay_number' => $data->alipay_number,
        ];
    }
}
